package 哈希表;

import java.util.HashMap;

public class 数组中只出现一次的两个数字 {
    public int[] FindNumsAppearOnce (int[] array) {
        int[] res = new int[2];
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < array.length; i++) {
            if (!map.containsKey(array[i])){
                map.put(array[i],1);
            }else{
                map.put(array[i],map.get(array[i])+1);
            }
        }
        int count = 0;
        for (int i : map.keySet()) {
            if (map.get(i) == 1){
                 res[count] = i;
                 count++;
            }
        }
        return res;
    }
}
